﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BasehInfoManagerViewModel.Common
{
    public class SearchModel
    {
        public SearchModel()
        {
            SearchItem = new Dictionary<string, string>();
            PageIndex = 1;
        }
        /// <summary>
        /// 当前页
        /// </summary>
        public int PageIndex { get; set; }
        /// <summary>
        /// 页长度
        /// </summary>
        public int PageSize { get; set; }
        private int _start;
        /// <summary>
        /// 起始记录
        /// </summary>
        public int Start
        {
            get
            {
                if (PageIndex > 0)
                {
                    return (PageIndex - 1) * PageSize;
                }
                return 0;
            }
            set
            {
                _start = value;
            }
        }
        /// <summary>
        /// 结束记录
        /// </summary>
        public int End
        {
            get
            {
                return PageSize + Start;
            }
        }
        /// <summary>
        /// 排序字段
        /// </summary>
        public string OrderBy { get; set; }
        /// <summary>
        /// 排序方式
        /// </summary>
        public OrderByType OrderByType { get; set; }
        /// <summary>
        /// 查询条件
        /// </summary>
        public Dictionary<string, string> SearchItem { get; set; }
    }

    public enum OrderByType
    {
        /// <summary>
        /// 正序
        /// </summary>
        ASC,
        /// <summary>
        /// 倒序
        /// </summary>
        DESC
    }
}
